package com.google.com.coma.tester;

import com.google.code.coma.domain.Computer;
import com.google.code.coma.domain.LifeCycleStep;
import com.google.code.coma.domain.Part;
import com.google.code.coma.domain.Type;
import com.google.code.coma.worker.AbstractWorker;
import com.google.code.coma.worker.Worker;
import org.apache.log4j.Logger;

import java.util.*;

/**
 */
public abstract class AbstractTesterWorker extends AbstractWorker implements Worker {
    protected static final Logger log = Logger.getLogger(AbstractTesterWorker.class);

    private final String workerId = "tester_worker" + UUID.randomUUID().toString();
    protected LifeCycleStep sourceStep;

	protected AbstractTesterWorker(String factoryId, LifeCycleStep sourceStep) {
		super(factoryId);
        this.sourceStep = sourceStep;
	}

	@Override
    public String getWorkerId() {
        return workerId;
    }

    protected List<Part> getNoneDefectComputerParts(Computer computer) {
        List<Part> parts = new ArrayList<Part>();

        for (Part part : computer.getParts()) {
            if (!part.isBroken()) {
                parts.add(part);
            }
        }

        return parts;
    }
}
